﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace QMERP.Infrastructure.EFCore.Migrations
{
    /// <inheritdoc />
    public partial class init23 : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AddColumn<long>(
                name: "ShipmentLogId",
                table: "LeaveStockOrder",
                type: "bigint",
                nullable: true);

            migrationBuilder.CreateTable(
                name: "ShipmentLog",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    ExpressCompanyName = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    ExpressNumber = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    IsEnable = table.Column<bool>(type: "bit", nullable: false),
                    CreatedBy = table.Column<long>(type: "bigint", nullable: false),
                    CreatedByName = table.Column<string>(type: "nvarchar(50)", nullable: false),
                    CreatedOn = table.Column<DateTime>(type: "datetime", nullable: false),
                    UpdatedBy = table.Column<long>(type: "bigint", nullable: true),
                    UpdatedByName = table.Column<string>(type: "nvarchar(50)", nullable: true),
                    UpdatedOn = table.Column<DateTime>(type: "datetime", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_ShipmentLog", x => x.Id);
                });

            migrationBuilder.CreateIndex(
                name: "IX_LeaveStockOrder_ShipmentLogId",
                table: "LeaveStockOrder",
                column: "ShipmentLogId");

            migrationBuilder.CreateIndex(
                name: "IX_ShipmentLog_CreatedOn",
                table: "ShipmentLog",
                column: "CreatedOn",
                descending: new bool[0]);

            migrationBuilder.CreateIndex(
                name: "IX_ShipmentLog_ExpressCompanyName",
                table: "ShipmentLog",
                column: "ExpressCompanyName");

            migrationBuilder.CreateIndex(
                name: "IX_ShipmentLog_ExpressNumber",
                table: "ShipmentLog",
                column: "ExpressNumber");

            migrationBuilder.CreateIndex(
                name: "IX_ShipmentLog_Id",
                table: "ShipmentLog",
                column: "Id");

            migrationBuilder.AddForeignKey(
                name: "FK_LeaveStockOrder_ShipmentLog_ShipmentLogId",
                table: "LeaveStockOrder",
                column: "ShipmentLogId",
                principalTable: "ShipmentLog",
                principalColumn: "Id");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_LeaveStockOrder_ShipmentLog_ShipmentLogId",
                table: "LeaveStockOrder");

            migrationBuilder.DropTable(
                name: "ShipmentLog");

            migrationBuilder.DropIndex(
                name: "IX_LeaveStockOrder_ShipmentLogId",
                table: "LeaveStockOrder");

            migrationBuilder.DropColumn(
                name: "ShipmentLogId",
                table: "LeaveStockOrder");
        }
    }
}
